<?php
class Autotype_model extends CI_Model{
	/**
	 * @author Pwint Phyu Shwe
	 * Poperty Category Model for tbl_category and tbl_adv_category tables
	 * CRUD of Property Category related.
	 * This model include pagination and related functions.
	 * Refer detail in each function's comment section below.
	 * This model is related to classified advertisements.
	 */
	// table name
	private $tbl_category = ' automobile_type';
	
	function __construct()
	{
		// Call the Model constructor
		parent::__construct();
	}
	// get number of users in database
	function count_all(){
		return $this->db->count_all($this->tbl_category);
	}
	
	//get description
	function get_types($cond = NULL){
		if ($cond != NULL){
			foreach ($cond as  $param => $item)
				$this->db->where($param , $item);
		}
		
		$query = $this->db->get($this->tbl_category);
		$result = array();
		$result[''] = 'select types';
		foreach ($query->result() as $row){
			$result[$row->id]= $row->auto_type;
		}
		$result['other'] = 'Other';
		$query->free_result(); //free result
		return $result;
	}
	//delete
	function delete($id){
		$this->db->where('id', $id);
		$this->db->delete($this->tbl_category);
	}
	//save
	function save($obj)
	{
		$this->db->insert($this->tbl_category, $obj);
		return $this->db->insert_id();
	}
	//update
	function  update($obj) {
		$this->db->where('id', $obj['id']);
		$this->db->update($this->tbl_category, $obj);
		
	}
	
	
	
}
?>